package com.es.message;

import java.util.ArrayList;
import java.util.HashMap;

import javax.servlet.http.HttpServletRequest;

import com.es.util.mail.SendMsg;
import com.opensymphony.webwork.interceptor.ServletRequestAware;
import com.opensymphony.xwork.ActionSupport;

public class NoticeSendDoAction extends ActionSupport implements ServletRequestAware{
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	HttpServletRequest request;
	 
   public String execute()throws Exception{
	   
	   MessageBiz  manegeBiz= new MessageBiz();
	   String real_salary = request.getParameter("real_salary")==null?"":request.getParameter("real_salary");
	   String ctmId = request.getParameter("ctmId")==null?"":request.getParameter("ctmId");
	   String message ="";
	   if("".equals(ctmId)){
		   message = "员工编号不存在，请重新发送";
		   request.setAttribute("message", message);
		   return "success"; 
	   }
	   if("".equals(real_salary)){
		   message = "短信内容不能为空，请输入短信内容!";
		   request.setAttribute("message", message);
		   return "success"; 
	   }
	   ArrayList<HashMap<String,String>> address = manegeBiz.getMsgList(ctmId,real_salary);
	   SendMsg.sendMsgForSalary(address);
	   message = "通知短信已发送,因网络延迟，可能稍后一段时间才能到达收信人";
	   request.setAttribute("message", message);
	   return "success";
   }

   public void setServletRequest(HttpServletRequest request) {
	     this.request = request;
  }
}